/**
 * Copyright 2011 Mathieu Magnaudet
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package edu.enac.geoapp.services;

import org.apache.log4j.Logger;
import org.geotools.referencing.CRS;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.NoSuchAuthorityCodeException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;

/**
 * Provides the default Coordinate Reference System (CRS).
 * 
 * @author mathieu
 * 
 */
public class CRSProvider {
	private static final CRSProvider INSTANCE = new CRSProvider();
	private CoordinateReferenceSystem standarCRS;
	private static Logger logger;

	private CRSProvider() {
		logger = Logger.getLogger(CRSProvider.class);
		try {
			initStandardCRS();

		} catch (Exception e) {
			logger.warn("unable to initialize CRS.\n" + e.getMessage());
		}
	}

	private void initStandardCRS() throws NoSuchAuthorityCodeException,
			FactoryException {
		standarCRS = CRS.decode("EPSG:4326");
	}

	public static CRSProvider getInstance() {
		return INSTANCE;
	}

	public CoordinateReferenceSystem getStandardCRS() {
		return standarCRS;
	}

	/**
	 * Should provide a specific CRS when a rotation is required NOT YET
	 * IMPLEMENTED and NOT SURE that it is the right way to do that
	 * 
	 * @return
	 */
	public CoordinateReferenceSystem getRotatedCRS() {
		// TODO Auto-generated method stub
		return null;
	}

}
